﻿
<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>生产计划创建</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <script src="~/js/layui/layui.js"></script>
    <link href="~/js/layui/css/layui.css" rel="stylesheet" />
    <link href="~/X-admin/css/xadmin.css" rel="stylesheet" />
    <script src="~/X-admin/js/jquery.min.js"></script>
    <script src="~/X-admin/js/xadmin.js"></script>
    <script src="~/js/framework/sysframework.js"></script>
    <script src="~/js/framework/commonjs.js"></script>

</head>
<body>
    <ul lay-bar="disabled" class="mWebBanner">
        <li class="layui-nav-item" style="float:left;">
            <button id="btn-Save" type="button" name="btn_update" onclick="savaData()" class="buttonCss">
                <i class="layui-icon" style="margin-right:3px">&#x1005;</i>确 定
            </button>
        </li>
        <li class="layui-nav-item" style="float:left;margin-left:3%">
            <button id="btn-sync" type="button" onclick="closeWin()" class="buttonCss">
                <i class="layui-icon" style="margin-right:3px">&#x1007;</i> 关 闭
            </button>
        </li>
    </ul>
    <div class="layui-card" style="margin-top:10px">
        <div class="layui-card-body" style="padding-top:4%">
            <form id="qForm" class="layui-form layui-col-space5" lay-filter="form-filter">

                <div class="layui-form-item">
                    <div class="layui-input-group" style="float:left;">
                        <div class="layui-input-prefix">
                           条码编码
                        </div>
                        <input type="text" id="barCode" name="barCode" class="layui-input" readonly />
                    </div>

                    <div class="layui-input-group" style="float:left;margin-left:5%">
                        <div class="layui-input-prefix">
                            存货名称
                        </div>
                        <input type="text" id="proName" name="proName" class="layui-input" style="width:140%" readonly />
                    </div>
                    <div class="layui-input-group" style="float:left;margin-left:11%">
                        <div class="layui-input-prefix">
                            规 格
                        </div>
                        <input type="text" id="spec" name="spec" class="layui-input" readonly />

                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-group" style="float:left;">
                        <div class="layui-input-prefix">
                            条码重量
                        </div>
                        <input type="text" id="proWeight" name="proWeight" class="layui-input" style="width:70%" readonly />
                    </div>

                    <div class="layui-input-group" style="float:left;margin-left:3%">
                        <div class="layui-input-prefix">
                            条码米数
                        </div>
                        <input type="text" id="proMeter" name="proMeter" class="layui-input" style="width:70%" readonly />
                    </div>
                    <div class="layui-input-group" style="float:left;margin-left:3%">
                        <div class="layui-input-prefix">
                            关联客户
                        </div>
                        <input type="text" id="cu_customer" name="cu_customer" class="layui-input" style="width:150%" readonly/>
                    </div>
                </div>
            
               </form>
            <form id="dForm" class="layui-form layui-col-space5" lay-filter="dform-filter">
                <div class="layui-form-item">
                    <div class="layui-input-group" style="float:left;">
                        <div class="layui-input-prefix">
                          检测米数
                        </div>
                        <input type="text" id="jcms" name="jcms" class="layui-input" style="width:70%">
                    </div>
                    <div class="layui-input-group" style="float:left;margin-left:3%">
                        <div class="layui-input-prefix">
                            废品米数
                        </div>
                        <input type="text" id="fpms" name="fpms" class="layui-input" style="width:70%">
                    </div>
                    <div class="layui-input-group" style="float:left;margin-left:4%">
                        <div class="layui-input-prefix">
                            废品率
                        </div>
                        <input type="text" id="fpl" name="fpl" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-group" style="float:left;">
                        <div class="layui-input-prefix">
                            原有接头数
                        </div>
                        <input type="text" id="ymlx" name="ymlx" class="layui-input">
                    </div>
                    <div class="layui-input-group" style="float:left;margin-left:5%">
                        <div class="layui-input-prefix">
                            检测接头数
                        </div>
                        <input type="text" id="jcjts" name="jcjts" class="layui-input">
                    </div>
                    <div class="layui-input-group" style="float:left;margin-left:5%">
                        <div class="layui-input-prefix">
                            检测结果
                        </div>
                        <select id="chResult" name="chResult">
                            <option value="1">合 格</option>
                            <option value="0">不合格</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-group" style="float:left;">
                        <div class="layui-input-prefix">
                            检测人员
                        </div>
                        <select id="user-title" name="user-title" lay-search="">
                        </select>
                    </div>
                </div>
            
            
                <div style="width:98%;overflow-x: auto;">
                    <table class="layui-table">
                        <tr>
                            <th style="width:10%">检测项</th>
                            <th style="width:40%">检测内容</th>
                            <th style="width:13%">检测结果</th>
                            <th>备 注</th>
                        </tr>
                        <tr>
                            <td>
                                <input type="text" id="table-yw-title" name="table-yw-title" class="layui-input" value="蚊虫异物" readonly>
                            </td>
                            <td>
                                <input type="text" id="table-yw-nr" name="table-yw-nr" class="layui-input">
                            </td>
                            <td>
                                <select id="table-yw-result" name="table-yw-result">
                                   <option value="">选择结果</option>
                                    <option value="1">合 格</option>
                                    <option value="0">不合格</option>
                               </select>
                            </td>
                            <td>
                                <input type="text" id="table-yw-memo" name="table-yw-memo" class="layui-input">
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <input type="text" id="table-md-title" name="table-md-title" class="layui-input" value="墨点" readonly>
                            </td>
                            <td>
                                <input type="text" id="table-md-nr" name="table-md-nr" class="layui-input">
                            </td>
                            <td>
                                <select id="table-md-result" name="table-md-result">
                                    <option value="">选择结果</option>
                                    <option value="1">合 格</option>
                                    <option value="0">不合格</option>
                                </select>
                            </td>
                            <td>
                                <input type="text" id="table-md-memo" name="table-md-memo" class="layui-input">
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <input type="text" id="table-bx-title" name="table-bx-title" class="layui-input" value="白线" readonly>
                            </td>
                            <td>
                                <input type="text" id="table-bx-nr" name="table-bx-nr" class="layui-input">
                            </td>
                            <td>
                                <select id="table-bx-result" name="table-bx-result">
                                    <option value="">选择结果</option>
                                    <option value="1">合 格</option>
                                    <option value="0">不合格</option>
                                </select>
                            </td>
                            <td>
                                <input type="text" id="table-bx-memo" name="table-bx-memo" class="layui-input">
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <input type="text" id="table-dx-title" name="table-dx-title" class="layui-input" value="刀线" readonly>
                            </td>
                            <td>
                                <input type="text" id="table-dx-nr" name="table-dx-nr" class="layui-input">
                            </td>
                            <td>
                                <select id="table-dx-result" name="table-dx-result">
                                    <option value="">选择结果</option>
                                    <option value="1">合 格</option>
                                    <option value="0">不合格</option>
                                </select>
                            </td>
                            <td>
                                <input type="text" id="table-dx-memo" name="table-dx-memo" class="layui-input">
                            </td>
                        </tr>
                    </table>
                </div>
                <input type="hidden" id="crCode" name="crCode" />
                <input type="hidden" id="id" name="id" />
            </form>
        </div>
    </div>

</body>

</html>


<script>

    var barCode = "",crCode="";

    $(function () {
        barCode = getUrlVariable("barCode");
        crCode = getUrlVariable("crCode");
        $("input[ name='barCode']").val(barCode);
        loadBarData();
        CheckUser();
        if (crCode != "") {
            loadCheckData();
        }
    })
    function loadBarData() {
        $.ajax({
            url: "../Bar/GetBarCodeInfoByCode",
            type: "post",
            data: { barCode: barCode },
            success: function (data) {
                if (data.result) {
                    var datas = data.data[0];
                    layui.use('form', function () {
                        var form = layui.form;
                        form.val('form-filter', datas);
                        form.render();
                    });
                }
            }
        });
    }
    function loadCheckData() {
        $.ajax({
            url: "../Quality/GetCheckRecordByCode",
            type: "post",
            data: {crCode: crCode },
            success: function (data) {
                if (data.result) {
                    var datas = data.data;
                    layui.use('form', function () {
                        var form = layui.form;
                        form.val('dform-filter', datas);
                        form.render();
                    });
                }
            }
        });
    }
    function savaData() {
        $.ajax({
            url: "../Quality/AddCheckRecords",
            type: "post",
            data: { barCode: barCode, datas: JSON.stringify(FormToJson("dForm")) },
            success: function (data) {
                if (data.result) {
                    layer.msg("数据保存成功", {icon:1}); closeWin();
                } else {
                    layer.msg(data.message, {icon:2});
                }

            }
        });
    }
    function CheckUser() {

        $.ajax({
            url: "../System/GetUserInfo",
            dataType: "json",
            type: "post",
            success: function (data) {
                var datas = data.data;
                for (var i = 0; i < datas.length; i++) {
                    $("#user-title").append("<option value=\"" + datas[i]["userCode"] + "\" >" + datas[i]["userName"] + "(" + datas[i]["userCode"] + ")" + "</option>");
                }
                if (defaultValue != undefined && defaultValue != "") {
                    $("#user-title option[value='" + defaultValue + "'] ").attr("selected", true);
                }
                layui.use('form', function () {
                    var form = layui.form;
                    form.render();
                });
            }
        });
    }
</script>

